from fileReader import TxtFileReader,JsonFileReader
from data_render import Recode
from pyecharts.charts import Bar
from pyecharts.options import *
from pyecharts.globals import ThemeType
txt_list_data = TxtFileReader('data.txt')
json_list_data = JsonFileReader('jsonData.txt')
txt_list:list[Recode] = txt_list_data.read_file()
json_list:list[Recode] = json_list_data.read_file()
newList:list[Recode] = txt_list + json_list
summit_dict = {}
for recode in newList:
    if recode.date in summit_dict:
        summit_dict[recode.date] += recode.money
    else:
        summit_dict[recode.date] = recode.money
for key in summit_dict:
    print(f"{key}的销售总额为{summit_dict[key]}元")

bar = Bar()
bar.add_xaxis(list(summit_dict.keys()))
bar.add_yaxis('销售额',list(summit_dict.values()))
bar.render('柱状图.html')
